/*
 * @lc app=leetcode.cn id=2591 lang=csharp
 *
 * [2591] 将钱分给最多的儿童
 */

// @lc code=start
public class Solution {
    public int DistMoney(int money, int children) {
        if (money < children)
            return -1;
        money -= children;
        
        var cnt = Math.Min(money / 7, children);
        money -= cnt * 7;
        children -= cnt;
        
        if ((children == 0 && money > 0) || (children == 1 && money == 3)) {
            cnt--;
        }
        return cnt;
    }
}
// @lc code=end

